<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const trueTypeOf = obj => {
        return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase()
      }

      console.log(trueTypeOf(''))
      // string
      console.log(trueTypeOf(0))
      // number
      console.log(trueTypeOf())
      // undefined
      console.log(trueTypeOf(null))
      // null
      console.log(trueTypeOf({}))
      // object
      console.log(trueTypeOf([]))
      // array
      console.log(trueTypeOf(0))
      // number
      console.log(trueTypeOf(() => {}))
      // function
    </script>
  </body>
</html>
